#include "gameswidget.h"
#include <QPushButton>
#include <QGridLayout>
#include <QFile>
#include <QSpacerItem>
#include "configargs.h"

GamesWidget::GamesWidget(QWidget *parent) : QWidget(parent)
{
    QPushButton *pGamesBtn = new QPushButton();
    pGamesBtn->setFocusPolicy(Qt::NoFocus);
    pGamesBtn->setObjectName("gamesBtn");

    QGridLayout *pMainLayout = new QGridLayout();
    pMainLayout->setMargin(SUBSPACE);
    pMainLayout->setSpacing(SUBSPACE);

    QSpacerItem *pSpacerItem = new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
    pMainLayout->addWidget(pGamesBtn, 0, 0, 1, 1);
    pMainLayout->addItem(pSpacerItem, 0, 1, 4, 4);
    pMainLayout->addItem(pSpacerItem, 1, 0, 3, 1);


    this->setLayout(pMainLayout);

    connect(pGamesBtn, SIGNAL(clicked(bool)), this, SIGNAL(painBtnClicked()));
    loadQss();
}

void GamesWidget::loadQss()
{
	QFile iconQss;
	QFile sizeQss;
	QString iconQssStr;
	QString sizeQssStr;

    if(g_lcdsize == LCDSIZE_1024x768 || g_lcdsize == LCDSIZE_1280x800){
		iconQss.setFileName(":/qss/linuxdesktop/stylesheet/gamesicon_1024x768.qss");
		sizeQss.setFileName(":/qss/linuxdesktop/stylesheet/gamessize_1024x768.qss");

	}else if(g_lcdsize == LCDSIZE_800x600){
		iconQss.setFileName(":/qss/linuxdesktop/stylesheet/gamesicon_800x600.qss");
		sizeQss.setFileName(":/qss/linuxdesktop/stylesheet/gamessize_800x600.qss");
	}else if(g_lcdsize == LCDSIZE_800x480){
		iconQss.setFileName(":/qss/linuxdesktop/stylesheet/gamesicon_800x480.qss");
		sizeQss.setFileName(":/qss/linuxdesktop/stylesheet/gamessize_800x480.qss");
	}else if(g_lcdsize == LCDSIZE_480x272){
		iconQss.setFileName(":/qss/linuxdesktop/stylesheet/gamesicon_800x480.qss");
		sizeQss.setFileName(":/qss/linuxdesktop/stylesheet/gamessize_480x272.qss");
	}

	iconQss.open(QFile::ReadOnly);
	sizeQss.open(QFile::ReadOnly);

	iconQssStr = iconQss.readAll();
	sizeQssStr = sizeQss.readAll();

	this->setStyleSheet(sizeQssStr + iconQssStr);

    
}
